<?php

use yii\db\Migration;

/**
 * Class m190613_010751_dgg_call
 */
class m190613_010751_dgg_cdr extends Migration
{
    /**
     * {@inheritdoc}
     */
    public function safeUp()
    {
        $tableOptions = null;
        if ($this->db->driverName === 'mysql') {
            // http://stackoverflow.com/questions/766809/whats-the-difference-between-utf8-general-ci-and-utf8-unicode-ci
            $tableOptions = 'CHARACTER SET utf8 COLLATE utf8_unicode_ci ENGINE=InnoDB';
        }
        $this->createTable('dgg_cdr', [
            'id' => $this->primaryKey(),
            'uniqueid' => $this->string(),
            'src' => $this->string(32),
            'dst' => $this->string(32),
            'cid' => $this->tinyInteger(2)->defaultValue(0),
            'calltime' => $this->timestamp(),
            'callsec' => $this->tinyInteger(3)->defaultValue(0),
            'record' => $this->string(),
            'call_line' => $this->string(),
            'phone_type' => $this->tinyInteger(3)->defaultValue(1),
            'direct' => $this->tinyInteger(3)->defaultValue(2),
            'created_at' => $this->timestamp(),
        ],$tableOptions);
    }

    /**
     * {@inheritdoc}
     */
    public function safeDown()
    {
        $this->dropTable('dgg_cdr');
    }

    /*
    // Use up()/down() to run migration code without a transaction.
    public function up()
    {

    }

    public function down()
    {
        echo "m190613_010751_dgg_call cannot be reverted.\n";

        return false;
    }
    */
}
